home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-serious-
/
programming
/
basic
/
mildred
/
lha
/
ilbmviewer.lha
/
Display.ascii
< prev
next >
Wrap
Text File
|
1999-03-07
|
6KB
|
160 lines
;Display
Statement Permit{}
;Permit multitasking, only if it is globally intended
SHARED Multitasking.b
If Multitasking Then Permit_
End Statement
Statement Forbid{}
;Disable multitasking, if it isn't globally intended
SHARED Multitasking.b
If Multitasking Then Forbid_
End Statement
Statement Multitasking{State.b}
;Toggle global multitasking on or off.
SHARED Multitasking.b
If State
If Multitasking=False Then Permit_
Else
If Multitasking Then Forbid_
EndIf
Multitasking=State
End Statement
Function.b InitDisplay{Title$}
;Creates a display
;Title$=The screen title (not displayed)
SHARED PrefDisplayHeight.w,PrefDisplayID.l,PrefDisplayBuffering.b,*ScrVP._ViewPort,IsAGA.b
SHARED ChunkyBase.l,ChunkyBuffer.l,PrefDisplayLeft.w,PrefDisplayTop.w
SHARED PrefDisplayDepth.w,PrefDisplayWidth.w,DisplaySplit.w,CPUminimum.b
SHARED PlanarBuf(),ILBMHAM.l
;Open a test screen first to a) test for AGA or GFX-Card, and b) because the dimensions might be
;too large to open a chipram screen, and the dimensions for AGA have not yet been reduced to within limits
Dim ScrTags.TagItem(13)
Rect.Rectangle\MinX=0,0,320,240 ; For test
ScrTags(0)\ti_Tag=#SA_Width,320 ; For test
ScrTags(1)\ti_Tag=#SA_Height,240; For test
ScrTags(2)\ti_Tag=#SA_Depth,PrefDisplayDepth
ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID
ScrTags(4)\ti_Tag=#SA_Type,$F
ScrTags(5)\ti_Tag=#SA_Quiet,True
ScrTags(6)\ti_Tag=#SA_ShowTitle,False
ScrTags(7)\ti_Tag=#SA_Behind,True
ScrTags(8)\ti_Tag=#SA_DClip,&Rect ; For test
ScrTags(9)\ti_Tag=#SA_Exclusive,True
ScrTags(10)\ti_Tag=#SA_Draggable,False
ScrTags(11)\ti_Tag=#SA_AutoScroll,True
ScrTags(12)\ti_Tag=#TAG_DONE,0
ScrTags(13)\ti_Tag=#TAG_DONE,0
UsedChip.l=(320 LSR 3)*PrefDisplayDepth*240 ; With test params
FreeChip.l=AvailMem_(#MEMF_CHIP)
Forbid{}
If ScreenTags(0,Title$,&ScrTags(0))<>0 ; Test for GFX-Card or AGA
NowChip.l=AvailMem_(#MEMF_CHIP)
Permit{}
If FreeChip-NowChip<UsedChip
; Graphics card screen
IsAGA=False
PrefDisplayWidth AND $FFE0 ; For gfx-cards, width to nearest 32
ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight*PrefDisplayBuffering
ScrTags(8)\ti_Tag=#SA_DClip,&Rect
VWait 25 ; seems to be necessary (safer)
Free Screen 0
VWait 10 ; just to be on the safe side
If ScreenTags(0,Title$,&ScrTags(0))<>0
For Loop.w=0 To PrefDisplayBuffering-1
If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
If Window(Loop,0,PrefDisplayHeight*Loop,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
Menus Off
ScreensBitMap 0,Loop
*TmpBmp.bitmap=Addr BitMap(Loop)
Offset.l=*TmpBmp\_ebwidth*(PrefDisplayHeight*Loop)
For DLoop.w=0 To PrefDisplayDepth-1
*TmpBmp\_data[DLoop]=*TmpBmp\_data[DLoop]+Offset
Next DLoop
Next Loop
Else
Function Return False
EndIf
Else
; AGA screen
IsAGA=True
PrefDisplayWidth AND $FFC0 ; For AGA, width to nearest 64
ScrTags(0)\ti_Tag=#SA_Width,PrefDisplayWidth
Rect.Rectangle\MinX=0,0,PrefDisplayWidth,PrefDisplayHeight
ScrTags(1)\ti_Tag=#SA_Height,PrefDisplayHeight ; Seperate buffers
ScrTags(8)\ti_Tag=#SA_DClip,&Rect
ScrTags(3)\ti_Tag=#SA_DisplayID,PrefDisplayID OR ILBMHAM
Forbid{}
VWait 25 ; seems to be necessary (safer)
Free Screen 0
For Loop.w=0 To PrefDisplayBuffering-1
If Loop=0 Then WFlags.l=$1900 Else WFlags.l=$800
If AvailMem_(#MEMF_CHIP)>=(PrefDisplayWidth*PrefDisplayHeight)+16
Memory.l=AllocMem((PrefDisplayWidth*PrefDisplayHeight)+16,$10002) ; Chip bitmap
Memory=(Memory+16) AND $FFFFFFF0 ; Align for move16's
If Memory<>0
CludgeBitMap Loop,PrefDisplayWidth,PrefDisplayHeight,PrefDisplayDepth,Memory
If Loop=0
ScrTags(12)\ti_Tag=#SA_BitMap,Addr BitMap(0)
If ScreenTags(0,Title$,&ScrTags(0))=0
Permit{}
Function Return False
EndIf
EndIf
If Window(Loop,0,0,PrefDisplayWidth,PrefDisplayHeight,WFlags,"",0,0)=0 Then Function Return False
Menus Off
Else
Permit{}
Function Return False
EndIf
Else
Permit{}
Function Return False
EndIf
PlanarBuf(Loop)=Memory
Next Loop
Permit{}
;AGA centering only (may not work on gfx card, or be necessary)
DEFTYPE.DimensionInfo DimInfoBuf
GetDisplayInfoData_ FindDisplayInfo_(PrefDisplayID) AND $FFFFFFFF,&DimInfoBuf,SizeOf.DimensionInfo,#DTAG_DIMS,0
PrefDisplayLeft.w=((DimInfoBuf\TxtOScan\MaxX)-PrefDisplayWidth)/2
PrefDisplayTop.w=((DimInfoBuf\TxtOScan\MaxY)-PrefDisplayHeight)/2
EndIf
DisplaySplit.w=((PrefDisplayWidth/4)*3) AND $FFF0 ; Horizontal coord at which splitscreen starts (mult of 16)
*Scr._Screen=NPeekL(Addr Screen(0))
*ScrVP=ViewPort(0)
*ScrVP\DxOffset=PrefDisplayLeft,PrefDisplayTop
ScrollVPort_ *ScrVP
RethinkDisplay_
Use Palette 0
Menus Off
If *ScrVP\DHeight<>PrefDisplayHeight
Forbid{}
*Scr\Height=PrefDisplayHeight ; Enforce y clipping
Permit{}
EndIf
ScreenToFront_ *Scr
; Make chunky buffer
NowFast.l=AvailMem_(#MEMF_FAST)
If NowFast<PrefDisplayWidth*(PrefDisplayHeight+#ChunkyClipTop+#ChunkyClipBottom)+16 Then Function Return False
ChunkyBase.l=AllocMem(PrefDisplayWidth*(PrefDisplayHeight+#ChunkyClipTop+#ChunkyClipBottom)+16,$10000)
If ChunkyBase=0 Then Function Return False
ChunkyBase=(ChunkyBase+16) AND $FFFFFFF0 ; Align for move16's
ChunkyBuffer.l=ChunkyBase+(#ChunkyClipTop*PrefDisplayWidth)
If IsAGA
Mc2pWindow 0,PrefDisplayWidth,PrefDisplayHeight,PrefDisplayWidth,CPUminimum,PrefDisplayWidth,PrefDisplayHeight
EndIf
Function Return True
Else
Permit{}
Function Return False
EndIf
End Function